{extend name="base"}
{block name="main"}
<h3>添加分类</h3>
<form action="{:url('admin/cate/add')}" method="post">
    <table width="70%" border="1" cellpadding="5" cellspacing="0" bgcolor="#cccccc">
        <tr>
            <td align="right">分类名称</td>
            <td><input type="text" name="cName" placeholder="请输入分类名称"/></td>
        </tr>
        <tr>
            <td colspan="2"><button id="submit" type="button" class="submit">添加分类</button></td>
        </tr>
    </table>
</form>

{load href='__PUBLIC__/static/js/jquery-3.1.1.min.js'}
<script type="text/javascript">
    $('.submit').click(function () {
        $.ajax({
            cache: true,
            type: "POST",
            url : '{:url('admin/admin/add')}',
            data: $('#addAdmin ').serialize(),
            async: false,
            success: function(data) {
                if (data.code) {
                    alert(data.msg);
                    setTimeout(function () {
                        location.href = data.url;
                    }, 1000);
                } else {
                alert(data.msg);
                }
            },
            error: function(request) {
                alert("页面错误");
            }
        });
    });
{/block}